package com.byxy.computer.student.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.byxy.computer.student.entity.HomeWork;
import com.byxy.computer.student.utils.HomeWorkData;

@Repository
public class HomeWorkDao {

	public List<HomeWork> findAll() {
		return HomeWorkData.lists;
	}

	public HomeWork save(HomeWork lm) {
		HomeWorkData.lists.add(lm);
		return lm;
	}

	public HomeWork findById(String id){
		for (HomeWork h : HomeWorkData.lists) {
			if (h.getId().equals(id)) {
				return h;
			}
		}
		return null;
	}
	public List<HomeWork> findByUid(String uid) {
		List<HomeWork> list = new ArrayList<HomeWork>();
		for (HomeWork h : HomeWorkData.lists) {
			if (h.getUid().equals(uid)) {
				list.add(h);
			}
		}
		return list;
	}
}
